package binarySearchTree;

/**
 * Data node.
 * @author xinruili
 * @version 1.0
 */
public class Contact {
    private String first;
    private String last;
    private String phone;

    /**
     * Construction method.
     * @param first first name
     * @param last last name
     * @param phone phonr
     */
    public Contact(final String first, final String last, final String phone) {
        this.first = first;
        this.last = last;
        this.phone = phone;
    }

    /**
     * Implementation of the comparison method.
     * @param contact Contrast target
     * @return Comparing results
     */
    public int compareTo(final Contact contact) {
        String value1 = first + last + phone;
        String value2 = contact.first
                + contact.last + contact.phone;
        return value1.compareTo(value2);
    }
}
